package com.orkasgb.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.orkasgb.common.CommonResult;
import com.orkasgb.entity.OrkasgbSubProcessEntity;
import com.orkasgb.service.IOrkasgbSubProcessService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.List;

/**
 * 子流程表(TOrkasgbSubProcess)表控制层
 *
 * @version 1.0.0
 * @since 2024-09-08 21:17:23
 */
@RestController
@RequestMapping("orkasgbSubProcess")
public class OrkasgbSubProcessController {
	
	/**
	 * 服务对象
	 */
	@Resource
	private IOrkasgbSubProcessService orkasgbSubProcessService;
	
	/**
	 * 通过主键查询单条数据
	 *
	 * @param id 主键
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbSubProcess/{id}")
	public CommonResult<OrkasgbSubProcessEntity> getOrkasgbSubProcess (@PathVariable("id") Serializable id) {
		return CommonResult.ofSuccess(orkasgbSubProcessService.getOrkasgbSubProcess(id));
	}
	
	/**
	 * 通过条件查询多条数据
	 *
	 * @param orkasgbSubProcess 实体查询参数
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbSubProcessList")
	public CommonResult<List<OrkasgbSubProcessEntity>> getOrkasgbSubProcessList (@ModelAttribute OrkasgbSubProcessEntity orkasgbSubProcess) {
		return CommonResult.ofSuccess(orkasgbSubProcessService.getOrkasgbSubProcessList(orkasgbSubProcess));
	}
	
	/**
	 * 通过条件查询多条数据(分页查询)
	 *
	 * @param orkasgbSubProcess 查询参数
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbSubProcessPageDataList")
	public CommonResult<IPage<OrkasgbSubProcessEntity>> getOrkasgbSubProcessPageDataList (@ModelAttribute OrkasgbSubProcessEntity orkasgbSubProcess) {
		return CommonResult.ofSuccess(new Page<OrkasgbSubProcessEntity>().setRecords(orkasgbSubProcessService.getOrkasgbSubProcessPageDataList(orkasgbSubProcess)));
	}
	
	/**
	 * 新增数据
	 *
	 * @param orkasgbSubProcess 实体对象
	 * @return 新增结果
	 */
	@PostMapping("addOrkasgbSubProcess")
	public CommonResult<Integer> addOrkasgbSubProcess (@RequestBody OrkasgbSubProcessEntity orkasgbSubProcess) {
		return CommonResult.ofSuccess(orkasgbSubProcessService.addOrkasgbSubProcess(orkasgbSubProcess));
	}
	
	/**
	 * 修改数据
	 *
	 * @param orkasgbSubProcess 实体对象
	 * @return 修改结果
	 */
	@PutMapping("updateOrkasgbSubProcess")
	public CommonResult<Integer> updateOrkasgbSubProcess (@RequestBody OrkasgbSubProcessEntity orkasgbSubProcess) {
		return CommonResult.ofSuccess(orkasgbSubProcessService.updateOrkasgbSubProcess(orkasgbSubProcess));
	}
	
	/**
	 * 修改或者新增数据
	 *
	 * @param orkasgbSubProcessList 实体对象
	 * @return 操作结果
	 */
	@PostMapping("addOrUpdateOrkasgbSubProcess")
	public CommonResult<Integer> addOrUpdateOrkasgbSubProcess (@RequestBody List<OrkasgbSubProcessEntity> orkasgbSubProcessList) {
		return CommonResult.ofSuccess(orkasgbSubProcessService.addOrUpdateOrkasgbSubProcess(orkasgbSubProcessList));
	}
	
	/**
	 * 删除数据
	 *
	 * @param idList 主键结合
	 * @return 删除结果
	 */
	@DeleteMapping("deleteOrkasgbSubProcessByIds")
	public CommonResult<Integer> deleteOrkasgbSubProcessByIds (@RequestParam("idList") List<Long> idList) {
		return CommonResult.ofSuccess(orkasgbSubProcessService.deleteOrkasgbSubProcessByIds(idList));
	}
	
}

